import 'package:flutter/material.dart';
import 'package:flutter_chip/config/Comm.dart';

class PaySuccess extends StatelessWidget {
  final String timestamp;
  final String out_trade_no;
  final String trade_no;
  final String total_amount;

  PaySuccess(
      this.timestamp, this.out_trade_no, this.trade_no, this.total_amount);

  Color txtColor = Colors.grey;
  double txtSize = 14;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("订单支付成功", style: TextStyle(fontSize: 18)),
        elevation: 0.0,
        backgroundColor: Theme.of(context).canvasColor,
        centerTitle: true,
      ),
      body: Column(
        children: <Widget>[
          _successPic(),
          SizedBox(height: 10),
          _tradeMoneyWidget(),
          SizedBox(height: 20),
          _tradeIdWidget(),
          SizedBox(height: 1),
          _orderIdWidget(),
          SizedBox(height: 1),
          _timeWidget(),
        ],
      ),
    );
  }

  Widget _successPic() {
    return Container(
      margin: EdgeInsets.only(top: 20),
      width: Comm.screenWidth,
      alignment: Alignment.topCenter,
      child: Image.asset(
        Comm.IMG_PAYSUCCESS,
        fit: BoxFit.fill,
        height: 96,
        width: 96,
      ),
    );
  }

  Widget _tradeMoneyWidget() {
    return Container(
      alignment: Alignment.center,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Row(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: <Widget>[
              Text(
                "$total_amount",
                style: TextStyle(
                  fontSize: 26,
                  color: Colors.red,
                  fontWeight: FontWeight.w600,
                ),
              ),
              Text(
                "元",
                style: TextStyle(
                  fontSize: 12,
                  color: Colors.red,
                ),
              ),
            ],
          ),
          Text(
            "订单金额",
            style: TextStyle(fontSize: 12, color: txtColor),
          ),
        ],
      ),
    );
  }

  Widget _orderIdWidget() {
    return Container(
      height: 48,
      color: Colors.white,
      padding: EdgeInsets.only(left: 10, right: 10),
      child: Row(
        children: <Widget>[
          Text(
            "商家订单号",
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
          Expanded(flex: 1, child: Container()),
          Text(
            out_trade_no,
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
        ],
      ),
    );
  }

  Widget _tradeIdWidget() {
    return Container(
      height: 48,
      color: Colors.white,
      padding: EdgeInsets.only(left: 10, right: 10),
      child: Row(
        children: <Widget>[
          Text(
            "交易单号",
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
          Expanded(flex: 1, child: Container()),
          Text(
            trade_no,
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
        ],
      ),
    );
  }

  Widget _timeWidget() {
    return Container(
      height: 48,
      color: Colors.white,
      padding: EdgeInsets.only(left: 10, right: 10),
      child: Row(
        children: <Widget>[
          Text(
            "交易时间",
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
          Expanded(flex: 1, child: Container()),
          Text(
            timestamp,
            style: TextStyle(fontSize: txtSize, color: txtColor),
          ),
        ],
      ),
    );
  }
}
